#!/bin/sh

set -e

cd "$(git rev-parse --show-toplevel)"

# pylint3 was replaced with pylint from Ubuntu 19.10
PYLINT=$(command -v pylint3) || true
if [ -z "$PYLINT" ]; then
    PYLINT=$(command -v pylint)
fi

find . -name \*.py \
    -and -not -path ./build\* \
    -and -not -path ./subprojects/\* \
    -and -not -path ./libos/test/ltp/src/\* \
    -and -not -path ./libos/test/ltp/build/\* \
    -and -not -path ./libos/test/ltp/install/\* \
    -and -not -name ninja_syntax.py \
| sed 's/./\\&/g' \
| xargs "${PYLINT}" "$@" \
    python/gramine-gen-depend \
    python/gramine-manifest \
    python/gramine-sgx-get-token \
    python/gramine-sgx-sign \
    python/gramine-test
